home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / ole2book.zip / CHAP11.ZIP / CHAP11 / COSCHMOO / IDROPSRC.CPP < prev    next >
C/C++ Source or Header  |  1993-06-13  |  3KB  |  146 lines

  1. /*
  2.  * IDROPSRC.CPP
  3.  *
  4.  * Implementation of a DropSource object.
  5.  *
  6.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Software Design Engineer
  9.  * Microsoft Systems Developer Relations
  10.  *
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "coschmoo.h"
  17.  
  18.  
  19.  
  20. /*
  21.  * CDropSource::CDropSource
  22.  * CDropSource::~CDropSource
  23.  *
  24.  * Constructor Parameters:
  25.  *  pDoc            LPSchmooDoc containing this interface.
  26.  */
  27.  
  28. CDropSource::CDropSource(LPCSchmooDoc pDoc)
  29.     {
  30.     m_cRef=0;
  31.     m_pDoc=pDoc;
  32.     return;
  33.     }
  34.  
  35. CDropSource::~CDropSource(void)
  36.     {
  37.     return;
  38.     }
  39.  
  40.  
  41.  
  42.  
  43. /*
  44.  * CDropSource::QueryInterface
  45.  * CDropSource::AddRef
  46.  * CDropSource::Release
  47.  *
  48.  * Purpose:
  49.  *  IUnknown members for CDropSource object.
  50.  */
  51.  
  52. STDMETHODIMP CDropSource::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  53.     {
  54.     *ppv=NULL;
  55.  
  56.     //Any interface on this object is the object pointer.
  57.     if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IDropSource))
  58.         *ppv=(LPVOID)this;
  59.  
  60.     /*
  61.      * If we actually assign an interface to ppv we need to AddRef it
  62.      * since we're returning a new pointer.
  63.      */
  64.     if (NULL!=*ppv)
  65.         {
  66.         ((LPUNKNOWN)*ppv)->AddRef();
  67.         return NOERROR;
  68.         }
  69.  
  70.     return ResultFromScode(E_NOINTERFACE);
  71.     }
  72.  
  73.  
  74. STDMETHODIMP_(ULONG) CDropSource::AddRef(void)
  75.     {
  76.     return ++m_cRef;
  77.     }
  78.  
  79. STDMETHODIMP_(ULONG) CDropSource::Release(void)
  80.     {
  81.     ULONG           cRefT;
  82.  
  83.     cRefT=--m_cRef;
  84.  
  85.     if (0L==m_cRef)
  86.         delete this;
  87.  
  88.     return cRefT;
  89.     }
  90.  
  91.  
  92.  
  93.  
  94.  
  95. /*
  96.  * CDropSource::QueryDragContinue
  97.  *
  98.  * Purpose:
  99.  *  Determines whether to continue a drag operation or cancel it.
  100.  *
  101.  * Parameters:
  102.  *  fEsc            BOOL indicating that the ESC key was pressed.
  103.  *  grfKeyState     DWORD providing states of keys and mouse buttons.
  104.  *
  105.  * Return Value:
  106.  *  SCODE           DRAGDROP_S_CANCEL to stop the drag, DRAGDROP_S_DROP
  107.  *                  to drop the data where it is, or NOERROR to continue.
  108.  */
  109.  
  110. STDMETHODIMP CDropSource::QueryContinueDrag(BOOL fEsc, DWORD grfKeyState)
  111.     {
  112.     if (fEsc)
  113.         return ResultFromScode(DRAGDROP_S_CANCEL);
  114.  
  115.     if (!(grfKeyState & MK_LBUTTON))
  116.         return ResultFromScode(DRAGDROP_S_DROP);
  117.  
  118.     return NOERROR;
  119.     }
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. /*
  127.  * CDropSource::GiveFeedback
  128.  *
  129.  * Purpose:
  130.  *  Provides cursor feedback to the user since the source task
  131.  *  always has the mouse capture.  We can also provide any other
  132.  *  type of feedback above cursors if we so desire.
  133.  *
  134.  * Parameters:
  135.  *  dwEffect        DWORD effect flags returned from the last target.
  136.  *
  137.  * Return Value:
  138.  *  SCODE           NOERROR if you set a cursor yourself or
  139.  *                  DRAGDROP_S_USEDEFAULTCURSORS to let OLE do the work.
  140.  */
  141.  
  142. STDMETHODIMP CDropSource::GiveFeedback(DWORD dwEffect)
  143.     {
  144.     return ResultFromScode(DRAGDROP_S_USEDEFAULTCURSORS);
  145.     }
  146.